local BBoy_TravelScreen = require "screens/bboy_travelscreen"

AddClassPostConstruct("screens/playerhud", function(self, anim, owner)
    self.BBoy_ShowTravelScreen = function(_, attach)
        if attach == nil then
            return
        else
            self.bboy_travelscreen = BBoy_TravelScreen(self.owner, attach)
            self:OpenScreenUnderPause(self.bboy_travelscreen)
            return self.bboy_travelscreen
        end
    end

    self.BBoy_CloseTravelScreen = function(_)
        if self.bboy_travelscreen then
            self.bboy_travelscreen:Close()
            self.bboy_travelscreen = nil
        end
    end
end)

-- 云雾
local BboyCloudsOver = require "widgets/bboycloudsover"

AddClassPostConstruct("screens/playerhud", function(self)
    -- 备份原方法
    local _CreateOverlays = self.CreateOverlays

    function self:CreateOverlays(owner)
        -- 先跑原版逻辑（会清空/重建各 root）
        _CreateOverlays(self, owner)

        -- 然后注入你的云雾 Widget
        if self.bboyclouds == nil then
            -- 选一层：overlayroot / over_root / under_root
            -- 不想遮 UI 就放 under_root；想做最上层纯视觉也可放 overlayroot
            self.bboyclouds = self.overlayroot:AddChild(BboyCloudsOver(owner))
            self.bboyclouds:Hide()
        end
    end

    -- 函数: 显示隐藏云雾
    function self:ShowBboyClouds(alpha)
        if self.bboyclouds ~= nil then
            if alpha ~= nil then
                self.bboyclouds.clouds:GetAnimState():SetMultColour(1, 1, 1, alpha)
            end
            self.bboyclouds:Show()
        end
    end

    function self:HideBboyClouds()
        if self.bboyclouds ~= nil then
            self.bboyclouds:Hide()
        end
    end
end)
